<script setup>
import {getWithdrawLogInfo, getWithdrawPayInfo} from '@/api/jdb.js'
import { useRouter, useRoute }                  from 'vue-router'
import { ref } from 'vue'
import { closeToast, showFailToast, showLoadingToast } from 'vant'

const router = useRouter()
const route = useRoute()

const id = ref(undefined)
const mchId = ref(undefined)
const packageInfo = ref(undefined)
const price = ref(undefined)
const name = ref(undefined)
const phone = ref(undefined)

const loading = ref(true)

if(!!route.query.id) {
  id.value = route.query.id
}

const onClickLeft = () => {
  router.replace('/withdraw-history')
}

const init = async () => {
  const toast = showLoadingToast({
    message: '正在查询收款结果 ...',
    forbidClick: true,
    duration: 0
  })
  setTimeout(() => {
    getWithdrawLogInfo({
      id: id.value,
    }).then(response => {
      price.value = response.data.price
      closeToast()
      loading.value = false
    })
  }, 5000)
}

init()
</script>

<template>
  <div v-if="!loading">
    <header class="withdraw-pay-success-header">提现成功</header>
    <section class="withdraw-pay-success-section">
      <span class="withdraw-pay-success-currency">¥</span>
      <span class="withdraw-pay-success-amount">{{price}}</span>
    </section>
    <section class="withdraw-pay-success-tips">
      可在“微信支付-服务-钱包-账单”查看明细
    </section>
    <footer class="withdraw-footer">
      <van-button type="success" size="normal" block @click="onClickLeft">返回</van-button>
    </footer>
  </div>
</template>

<style scoped>
.withdraw-pay-success-header {
  font-size:18px;
  margin-top:32px;
  text-align: center;
}
.withdraw-pay-success-section {
  align-items: center;
  display: flex;
  margin-top:20px;
  margin-bottom: 20px;
  justify-content: center;
}
.withdraw-pay-success-currency {
  font-size:16px;
}
.withdraw-pay-success-amount {
  margin-left:12px;
  font-size:36px;
}
.withdraw-pay-success-tips {
  margin-top:20px;
  font-size:12px;
  text-align: center;
  color: #666;
}

.withdraw-footer {
  width: 90%;
  margin: 100px auto 0;
  text-align: center;
}
</style>
